﻿Imports System.Data.OleDb
Public Class PartyList
    Dim cmd As OleDbCommand
    Dim dr As OleDbDataReader

    Private Sub PartyList_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Master.Enabled = True
    End Sub

    Private Sub PartyList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            fillgrid()
        Catch ex As Exception

        End Try
    End Sub
    Private Sub fillgrid()
        Dim str As String
        str = "select distinct(customer_name) from customer_master"
        cmd = New OleDbCommand(str, con)
        dr = cmd.ExecuteReader
        DataGridView1.Rows.Clear()
        While dr.Read
            DataGridView1.Rows.Add()
        End While
        cmd = New OleDbCommand(str, con)
        dr = cmd.ExecuteReader
        Dim i As Integer
        While dr.Read
            DataGridView1.Item(1, i).Value = dr(0).ToString
            i = i + 1
        End While
    End Sub
    Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclose.Click
        If btnclose.Text = "Clear" Then
            fillgrid()
            btnclose.Text = "Close"
        ElseIf btnclose.Text = "Close" Then
            Me.Close()
        End If
    End Sub
    Private Sub btnprint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprint.Click
        Try
            Dim i As Integer
            Dim count As Integer
            Dim j As Integer
            Dim rcount As Integer
            rcount = DataGridView1.Rows.Count
            While i < rcount
                If DataGridView1.Item(0, i).Value = True Then
                    count = count + 1
                End If
                i = i + 1
            End While
            i = 0
            Dim l(count) As String
            Dim bsel(count) As Boolean
            While i < rcount
                If DataGridView1.Item(0, i).Value = True Then
                    l(j) = DataGridView1.Item(1, i).Value
                    bsel(j) = DataGridView1.Item(2, i).Value
                    j = j + 1
                End If
                i = i + 1
            End While
            report.reportclosing(l, j, bsel)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
        btnclose.Text = "Clear"
    End Sub
End Class